package edu.task.snake.model;


import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Arena {

    private static Random random = new Random(System.currentTimeMillis());
    private int height;
    private int width;

    private Object[][] grid;
    private Snake snake;
    private List<Frog> frogs = new ArrayList<Frog>();

    public Arena(int height, int width) {
        this.grid = new Object[height][width];
        this.height = height;
        this.width = width;
        grid = new Object[height][width];
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                grid[j][i] = null;
            }
        }

        for (int i = 0; i < 5; i++) {
            int x = random.nextInt(width);
            int y = random.nextInt(height);
            while (grid[y][x] != null) {
                x = random.nextInt(width);
                y = random.nextInt(height);
            }
            while (grid[y][x] != null) {
                x = random.nextInt(width);
                y = random.nextInt(height);
            }
            grid[y][x] = new Frog(x, y);
            frogs.add((Frog) grid[y][x]);
        }

    }

    public List<Frog> getFrogs() {
        return frogs;
    }

    public Snake getSnake() {
        return snake;
    }

    public Object[][] getGrid() {
        return grid;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }
}
